const connection = require("../app/database")

class LabelService {
  async create(name) {
    const statement = "INSERT INTO label (name) VALUES (?);"
    const [res] = await connection.execute(statement, [name])
    return res
  }

  async list(limit = 3, offset = 0) {
    const statement = "SELECT * FROM label LIMIT ? OFFSET ?;"
    const [res] = await connection.execute(statement, [limit, offset])
    return res
  }

  async queryLabelByName(name) {
    const statement = "SELECT * FROM label WHERE name = ?;"
    const [res] = await connection.execute(statement, [name])
    return res
  }
}

module.exports = new LabelService()
